<!--********************************************************************
* Copyright© 2000 - 2025 SuperMap Software Co.Ltd. All rights reserved.
*********************************************************************-->
<!DOCTYPE html>
<html>
<head>
    <meta charset="UTF-8">
    <title data-i18n="resources.title_themeRange"></title>
    <script type="text/javascript" src="../js/include-web.js"></script>
</head>
<body style=" margin: 0;overflow: hidden;background: #fff;width: 100%;height:100%;position: absolute;top: 0;">
<div id="map" style="margin:0 auto;width: 100%;height: 100%"></div>
<script type="text/javascript" src="../../dist/leaflet/include-leaflet.js"></script>
<script type="text/javascript">
    var host = window.isLocal ? window.server : "https://iserver.supermap.io";
    var map, themeService, themeRange, themeParameters, themeLayer,
        url = host + "/iserver/services/map-china/rest/maps/China";
    map = L.map('map', {
        center: [30, 84],
        maxZoom: 18,
        zoom: 4
    });
    new L.supermap.TiledMapLayer(url, {noWrap: true, transparent: true}).addTo(map);
    createTheme();

    function createTheme() {
        themeService = new L.supermap.ThemeService(url);
        var themeRangeItem1 = new L.supermap.ThemeRangeItem({
            start: 0,
            end: 500000000000,
            style: new L.supermap.ServerStyle({
                fillForeColor: new L.supermap.ServerColor(211, 255, 250),
                lineColor: new L.supermap.ServerColor(179, 209, 193),
                lineWidth: 0.1
            })
        });
        var themeRangeItem2 = new L.supermap.ThemeRangeItem({
            start: 500000000000,
            end: 1000000000000,
            style: new L.supermap.ServerStyle({
                fillForeColor: new L.supermap.ServerColor(178, 218, 199),
                lineColor: new L.supermap.ServerColor(179, 209, 193),
                lineWidth: 0.1
            })
        });
        var themeRangeItem3 = new L.supermap.ThemeRangeItem({
            start: 1000000000000,
            end: 3000000000000,
            style: new L.supermap.ServerStyle({
                fillForeColor: new L.supermap.ServerColor(58, 178, 166),
                lineColor: new L.supermap.ServerColor(179, 209, 193),
                lineWidth: 0.1
            })
        });
        themeRange = new L.supermap.ThemeRange({
            rangeExpression: "SMAREA",
            rangeMode: L.supermap.RangeMode.EQUALINTERVAL,
            items: [themeRangeItem1, themeRangeItem2, themeRangeItem3]
        });
        themeParameters = new L.supermap.ThemeParameters({
            datasetNames: ["Province_R"],
            dataSourceNames: ["China"],
            joinItems: null,
            themes: [themeRange]
        });
        themeService.getThemeInfo(themeParameters).then(function (serviceResult) {
            var result = serviceResult.result;
            if (result && result.newResourceID) {
                themeLayer = new L.supermap.TiledMapLayer(url, {
                    noWrap: true,
                    cacheEnabled: false,
                    transparent: true,
                    layersID: result.newResourceID
                }).addTo(map);
            }
        });
    }
</script>
</body>
</html>